Module uri
A “URI” is a “Uniform Resource Identifier”. The IETF standard says a URI string looks like this:
[scheme:]scheme-specific-part[#fragment]
A common type, a hierarchical URI, looks like this:
[scheme:][//authority][path][?query][#fragment]
For example the string 'https://tarantool.org/x.html#y'
has three components:
httpsis the scheme,tarantool.org/x.htmlis the path,yis the fragment.
Tarantool’s URI module provides routines which convert URI strings into their components, or turn components into URI strings.
Below is a list of all uri functions.
| Name | Use |
|---|---|
| uri.parse() | Get a table of URI components |
| uri.format() | Construct a URI from components |
-
uri.parse(URI-string) Parameters: - URI-string – a Uniform Resource Identifier
Return: URI-components-table. Possible components are fragment, host, login, password, path, query, scheme, service.
Rtype: Table
Example:
tarantool> uri = require('uri') --- ... tarantool> uri.parse('http://x.html#y') --- - host: x.html scheme: http fragment: y ...
-
uri.format(URI-components-table[, include-password]) Parameters: - URI-components-table – a series of name:value pairs, one for each component
- include-password – boolean. If this is supplied and is
true, then the password component is rendered in clear text, otherwise it is omitted.
Return: URI-string. Thus uri.format() is the reverse of uri.parse().
Rtype: Example:
tarantool> uri.format({host = 'x.html', scheme = 'http', fragment = 'y'}) --- - http://x.html#y ...